package com.jiangtai.training.ui.achievement

import android.view.View
import android.widget.ImageView
import android.widget.TextView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.jiangtai.training.R
import com.jiangtai.training.bean.Person
import com.jiangtai.training.constant.Constant

/**
 * Created by heCunCun on 2021/3/8
 */
class AchievementAdapter:BaseQuickAdapter<Person,BaseViewHolder>(R.layout.item_achievement) {
    override fun convert(helper: BaseViewHolder, item: Person?) {
        item?:return
          helper.setText(R.id.tv_name,item.name)
          helper.setText(R.id.tv_id,item.personId)
        val tvTaskState = helper.getView<TextView>(R.id.tv_task_state)
        val ivLocation = helper.getView<ImageView>(R.id.iv_location)
         when(item.state){
            Constant.STATE_PRE->{
                tvTaskState.text = "未开始"
                tvTaskState.setTextColor(mContext.getColor(R.color.color_gray_BDBDBD))
                ivLocation.visibility=View.INVISIBLE
                helper.setText(R.id.tv_task_state,"未开始")
            }
            Constant.STATE_RUNNING->{
                if (item.projectId =="E100"){
                    ivLocation.visibility=View.VISIBLE
                }else{
                    ivLocation.visibility=View.INVISIBLE
                }

                tvTaskState.setTextColor(mContext.getColor(R.color.color_blue_2979FF))
                tvTaskState.text = "考核中"
            }
            Constant.STATE_FINISHED->{
                ivLocation.visibility=View.INVISIBLE
                tvTaskState.setTextColor(mContext.getColor(R.color.color_gray_BDBDBD))
                tvTaskState.text = "已完成"
            }
        }
        val tvScore = helper.getView<TextView>(R.id.tv_score)
        if (item.score!=""){
            helper.setText(R.id.tv_score,item.score)
            tvScore.setTextColor(mContext.getColor(R.color.color_blue_2979FF))
            tvScore.paint.isFakeBoldText=false
            tvScore.setBackgroundResource(R.color.color_gray_FAFAFA)
        }else{
            //没成绩可以录入
            helper.addOnClickListener(R.id.tv_score)
            tvScore.setTextColor(mContext.getColor(R.color.white))
            tvScore.setPadding(20,5,20,5)
            tvScore.paint.isFakeBoldText=true
            tvScore.text = "录入"
            tvScore.setBackgroundResource(R.drawable.shape_bg_btn_blue29_round)
        }




    }
}